<template>
  <div class="list">
    <p class="title"><span class="overflow-one">{{title}}</span></p>
    <ul class="list-cont" v-if="list.length">
      <li class="first-items">
        <span class="xuhao">序号</span>
        <span class="date">日期</span>
        <span class="time">时间</span>
      </li>
      <li class="list-items border-bottom" v-for="(item,index) in list" :key="index">
        <span class="xuhao">{{index+1}}</span>
        <span class="date">{{item.open_date}}</span>
        <span class="time">{{item.class_time}}</span>
      </li>
      
    </ul>
    <p v-else class="noData"><van-loading type="spinner" color="#1989fa" /></p>
    <div class="callSholl" @click="makePhoneCall">联系校区</div>
  </div>
</template>

<script>
export default {
  props:{
    title:{
      type: String,
      default: ""
    },
    phoneNumber:{
      type: String,
      default: ""
    },
    list: {
      type: Array,
      default: []
    }
  },
  methods: {
    makePhoneCall() {
      let that = this;
      if(!that.phoneNumber){
        wx.showToast({
          title: '该校区未设置联系电话！',
          icon: 'none',
          duration: 1500,
        });
        return
      }
      wx.makePhoneCall({
        phoneNumber: that.phoneNumber,
        success: function() {
          
        },
        fail: function() {
          wx.showToast({
            title: '拨打失败',
            icon: 'none',
            duration: 1500,
          });
        }
      })
    }
  },  
}
</script>

<style lang="less" scope>
.list{
  width: 100%;
  .noData{
    width: 100%;
    height: calc(~"100vh - 100px");
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .title{
    width: 100%;
    height: 50px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 0 40px 0 22px;
    box-sizing: border-box;
    background: #FFF7D6;
    span{
      display: block;
      width: 100%;
      font-size: 14px;
      color: #666;
    }
  }
  .callSholl{
    width: 100%;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    color: #fff;
    background: #00b7ee;
    position: fixed;
    bottom: 0;
    -webkit-overflow-scroll: touch;
  }
  .list-cont{
    width: 100%;
    height: calc(~"100vh - 146px");
    overflow: hidden;
    overflow-y: auto;
    .list-items{
      width: 100%;
      height: 44px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      color: #414040;
      font-size: 12px;
    }
    .first-items{
      width: 100%;
      height: 34px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      background: #F1F2F7;
      color: #A8A8A8;
      font-size: 12px;
    }
    .xuhao{
      min-width: 20%;
      width: 20%;
      text-align: center;
    }
    .time{
      min-width: 33%;
      width: 33%;
      text-align: center;
    }
    .date{
      flex-grow: 1;
      text-align: center;
    }
    
  }
}
</style>